/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.vinavac.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Quang <quangtin3@gmail.com>
 */
@Entity
@Table(name = "subject")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Subject.findAll", query = "SELECT s FROM Subject s"),
    @NamedQuery(name = "Subject.findById", query = "SELECT s FROM Subject s WHERE s.id = :id"),
    @NamedQuery(name = "Subject.findBySubjectCode", query = "SELECT s FROM Subject s WHERE s.subjectCode = :subjectCode"),
    @NamedQuery(name = "Subject.findByPhoneNumber", query = "SELECT s FROM Subject s WHERE s.phoneNumber = :phoneNumber"),
    @NamedQuery(name = "Subject.findByBaseline", query = "SELECT s FROM Subject s WHERE s.baseline = :baseline"),
    @NamedQuery(name = "Subject.findByIsPregnanted", query = "SELECT s FROM Subject s WHERE s.isPregnanted = :isPregnanted"),
    @NamedQuery(name = "Subject.findByDeliveryExpectationDate", query = "SELECT s FROM Subject s WHERE s.deliveryExpectationDate = :deliveryExpectationDate"),
    @NamedQuery(name = "Subject.findByDeliveryDate", query = "SELECT s FROM Subject s WHERE s.deliveryDate = :deliveryDate"),
    @NamedQuery(name = "Subject.findByIsAsf", query = "SELECT s FROM Subject s WHERE s.isAsf = :isAsf"),
    @NamedQuery(name = "Subject.findByAsfStartDate", query = "SELECT s FROM Subject s WHERE s.asfStartDate = :asfStartDate"),
    @NamedQuery(name = "Subject.findByLmpDate", query = "SELECT s FROM Subject s WHERE s.lmpDate = :lmpDate"),
    @NamedQuery(name = "Subject.findByBloodAnthroA", query = "SELECT s FROM Subject s WHERE s.bloodAnthroA = :bloodAnthroA"),
    @NamedQuery(name = "Subject.findByBloodAnthroB", query = "SELECT s FROM Subject s WHERE s.bloodAnthroB = :bloodAnthroB"),
    @NamedQuery(name = "Subject.findByBloodAnthroC", query = "SELECT s FROM Subject s WHERE s.bloodAnthroC = :bloodAnthroC"),
    @NamedQuery(name = "Subject.findByBloodAnthroD", query = "SELECT s FROM Subject s WHERE s.bloodAnthroD = :bloodAnthroD"),
    @NamedQuery(name = "Subject.findByBloodAnthroE", query = "SELECT s FROM Subject s WHERE s.bloodAnthroE = :bloodAnthroE"),
    @NamedQuery(name = "Subject.findByBloodAnthroF", query = "SELECT s FROM Subject s WHERE s.bloodAnthroF = :bloodAnthroF"),
    @NamedQuery(name = "Subject.findByDietaryRecallA1", query = "SELECT s FROM Subject s WHERE s.dietaryRecallA1 = :dietaryRecallA1"),
    @NamedQuery(name = "Subject.findByDietaryRecallA2", query = "SELECT s FROM Subject s WHERE s.dietaryRecallA2 = :dietaryRecallA2"),
    @NamedQuery(name = "Subject.findByDietaryRecallA3", query = "SELECT s FROM Subject s WHERE s.dietaryRecallA3 = :dietaryRecallA3"),
    @NamedQuery(name = "Subject.findByDietaryRecallA4", query = "SELECT s FROM Subject s WHERE s.dietaryRecallA4 = :dietaryRecallA4"),
    @NamedQuery(name = "Subject.findByDietaryRecallB1", query = "SELECT s FROM Subject s WHERE s.dietaryRecallB1 = :dietaryRecallB1"),
    @NamedQuery(name = "Subject.findByDietaryRecallB2", query = "SELECT s FROM Subject s WHERE s.dietaryRecallB2 = :dietaryRecallB2"),
    @NamedQuery(name = "Subject.findByDietaryRecallC1", query = "SELECT s FROM Subject s WHERE s.dietaryRecallC1 = :dietaryRecallC1"),
    @NamedQuery(name = "Subject.findByDietaryRecallC2", query = "SELECT s FROM Subject s WHERE s.dietaryRecallC2 = :dietaryRecallC2"),
    @NamedQuery(name = "Subject.findByUltraSound01", query = "SELECT s FROM Subject s WHERE s.ultraSound01 = :ultraSound01"),
    @NamedQuery(name = "Subject.findByUltraSound02", query = "SELECT s FROM Subject s WHERE s.ultraSound02 = :ultraSound02"),
    @NamedQuery(name = "Subject.findByUltraSound03", query = "SELECT s FROM Subject s WHERE s.ultraSound03 = :ultraSound03")})
public class Subject implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID")
    private Integer id;
    @Size(max = 32)
    @Column(name = "SUBJECT_CODE")
    private String subjectCode;
    @Size(max = 32)
    @Column(name = "PHONE_NUMBER")
    private String phoneNumber;
    @Column(name = "BASELINE")
    @Temporal(TemporalType.DATE)
    private Date baseline;
    @Column(name = "IS_PREGNANTED")
    private Boolean isPregnanted;
    @Column(name = "DELIVERY_EXPECTATION_DATE")
    @Temporal(TemporalType.DATE)
    private Date deliveryExpectationDate;
    @Column(name = "DELIVERY_DATE")
    @Temporal(TemporalType.DATE)
    private Date deliveryDate;
    @Column(name = "IS_ASF")
    private Boolean isAsf;
    @Column(name = "ASF_START_DATE")
    @Temporal(TemporalType.DATE)
    private Date asfStartDate;
    @Column(name = "LMP_DATE")
    @Temporal(TemporalType.DATE)
    private Date lmpDate;
    @Column(name = "BLOOD_ANTHRO_A")
    @Temporal(TemporalType.DATE)
    private Date bloodAnthroA;
    @Column(name = "BLOOD_ANTHRO_B")
    @Temporal(TemporalType.DATE)
    private Date bloodAnthroB;
    @Column(name = "BLOOD_ANTHRO_C")
    @Temporal(TemporalType.DATE)
    private Date bloodAnthroC;
    @Column(name = "BLOOD_ANTHRO_D")
    @Temporal(TemporalType.DATE)
    private Date bloodAnthroD;
    @Column(name = "BLOOD_ANTHRO_E")
    @Temporal(TemporalType.DATE)
    private Date bloodAnthroE;
    @Column(name = "BLOOD_ANTHRO_F")
    @Temporal(TemporalType.DATE)
    private Date bloodAnthroF;
    @Column(name = "DIETARY_RECALL_A1")
    @Temporal(TemporalType.DATE)
    private Date dietaryRecallA1;
    @Column(name = "DIETARY_RECALL_A2")
    @Temporal(TemporalType.DATE)
    private Date dietaryRecallA2;
    @Column(name = "DIETARY_RECALL_A3")
    @Temporal(TemporalType.DATE)
    private Date dietaryRecallA3;
    @Column(name = "DIETARY_RECALL_A4")
    @Temporal(TemporalType.DATE)
    private Date dietaryRecallA4;
    @Column(name = "DIETARY_RECALL_B1")
    @Temporal(TemporalType.DATE)
    private Date dietaryRecallB1;
    @Column(name = "DIETARY_RECALL_B2")
    @Temporal(TemporalType.DATE)
    private Date dietaryRecallB2;
    @Column(name = "DIETARY_RECALL_C1")
    @Temporal(TemporalType.DATE)
    private Date dietaryRecallC1;
    @Column(name = "DIETARY_RECALL_C2")
    @Temporal(TemporalType.DATE)
    private Date dietaryRecallC2;
    @Column(name = "ULTRA_SOUND_01")
    @Temporal(TemporalType.DATE)
    private Date ultraSound01;
    @Column(name = "ULTRA_SOUND_02")
    @Temporal(TemporalType.DATE)
    private Date ultraSound02;
    @Column(name = "ULTRA_SOUND_03")
    @Temporal(TemporalType.DATE)
    private Date ultraSound03;
    @JoinColumn(name = "STUDY_STATUS", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private StudyStatus studyStatus;
    @JoinColumn(name = "STUDY_GROUP", referencedColumnName = "ID")
    @ManyToOne
    private StudyGroup studyGroup;
    @JoinColumn(name = "VILLAGE", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Village village;

    public Subject() {
    }

    public Subject(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getSubjectCode() {
        return subjectCode;
    }

    public void setSubjectCode(String subjectCode) {
        this.subjectCode = subjectCode;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public Date getBaseline() {
        return baseline;
    }

    public void setBaseline(Date baseline) {
        this.baseline = baseline;
    }

    public Boolean getIsPregnanted() {
        return isPregnanted;
    }

    public void setIsPregnanted(Boolean isPregnanted) {
        this.isPregnanted = isPregnanted;
    }

    public Date getDeliveryExpectationDate() {
        return deliveryExpectationDate;
    }

    public void setDeliveryExpectationDate(Date deliveryExpectationDate) {
        this.deliveryExpectationDate = deliveryExpectationDate;
    }

    public Date getDeliveryDate() {
        return deliveryDate;
    }

    public void setDeliveryDate(Date deliveryDate) {
        this.deliveryDate = deliveryDate;
    }

    public Boolean getIsAsf() {
        return isAsf;
    }

    public void setIsAsf(Boolean isAsf) {
        this.isAsf = isAsf;
    }

    public Date getAsfStartDate() {
        return asfStartDate;
    }

    public void setAsfStartDate(Date asfStartDate) {
        this.asfStartDate = asfStartDate;
    }

    public Date getLmpDate() {
        return lmpDate;
    }

    public void setLmpDate(Date lmpDate) {
        this.lmpDate = lmpDate;
    }

    public Date getBloodAnthroA() {
        return bloodAnthroA;
    }

    public void setBloodAnthroA(Date bloodAnthroA) {
        this.bloodAnthroA = bloodAnthroA;
    }

    public Date getBloodAnthroB() {
        return bloodAnthroB;
    }

    public void setBloodAnthroB(Date bloodAnthroB) {
        this.bloodAnthroB = bloodAnthroB;
    }

    public Date getBloodAnthroC() {
        return bloodAnthroC;
    }

    public void setBloodAnthroC(Date bloodAnthroC) {
        this.bloodAnthroC = bloodAnthroC;
    }

    public Date getBloodAnthroD() {
        return bloodAnthroD;
    }

    public void setBloodAnthroD(Date bloodAnthroD) {
        this.bloodAnthroD = bloodAnthroD;
    }

    public Date getBloodAnthroE() {
        return bloodAnthroE;
    }

    public void setBloodAnthroE(Date bloodAnthroE) {
        this.bloodAnthroE = bloodAnthroE;
    }

    public Date getBloodAnthroF() {
        return bloodAnthroF;
    }

    public void setBloodAnthroF(Date bloodAnthroF) {
        this.bloodAnthroF = bloodAnthroF;
    }

    public Date getDietaryRecallA1() {
        return dietaryRecallA1;
    }

    public void setDietaryRecallA1(Date dietaryRecallA1) {
        this.dietaryRecallA1 = dietaryRecallA1;
    }

    public Date getDietaryRecallA2() {
        return dietaryRecallA2;
    }

    public void setDietaryRecallA2(Date dietaryRecallA2) {
        this.dietaryRecallA2 = dietaryRecallA2;
    }

    public Date getDietaryRecallA3() {
        return dietaryRecallA3;
    }

    public void setDietaryRecallA3(Date dietaryRecallA3) {
        this.dietaryRecallA3 = dietaryRecallA3;
    }

    public Date getDietaryRecallA4() {
        return dietaryRecallA4;
    }

    public void setDietaryRecallA4(Date dietaryRecallA4) {
        this.dietaryRecallA4 = dietaryRecallA4;
    }

    public Date getDietaryRecallB1() {
        return dietaryRecallB1;
    }

    public void setDietaryRecallB1(Date dietaryRecallB1) {
        this.dietaryRecallB1 = dietaryRecallB1;
    }

    public Date getDietaryRecallB2() {
        return dietaryRecallB2;
    }

    public void setDietaryRecallB2(Date dietaryRecallB2) {
        this.dietaryRecallB2 = dietaryRecallB2;
    }

    public Date getDietaryRecallC1() {
        return dietaryRecallC1;
    }

    public void setDietaryRecallC1(Date dietaryRecallC1) {
        this.dietaryRecallC1 = dietaryRecallC1;
    }

    public Date getDietaryRecallC2() {
        return dietaryRecallC2;
    }

    public void setDietaryRecallC2(Date dietaryRecallC2) {
        this.dietaryRecallC2 = dietaryRecallC2;
    }

    public Date getUltraSound01() {
        return ultraSound01;
    }

    public void setUltraSound01(Date ultraSound01) {
        this.ultraSound01 = ultraSound01;
    }

    public Date getUltraSound02() {
        return ultraSound02;
    }

    public void setUltraSound02(Date ultraSound02) {
        this.ultraSound02 = ultraSound02;
    }

    public Date getUltraSound03() {
        return ultraSound03;
    }

    public void setUltraSound03(Date ultraSound03) {
        this.ultraSound03 = ultraSound03;
    }

    public StudyStatus getStudyStatus() {
        return studyStatus;
    }

    public void setStudyStatus(StudyStatus studyStatus) {
        this.studyStatus = studyStatus;
    }

    public StudyGroup getStudyGroup() {
        return studyGroup;
    }

    public void setStudyGroup(StudyGroup studyGroup) {
        this.studyGroup = studyGroup;
    }

    public Village getVillage() {
        return village;
    }

    public void setVillage(Village village) {
        this.village = village;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Subject)) {
            return false;
        }
        Subject other = (Subject) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getSubjectCode() + "(Group " + getStudyGroup().getId() + ")";
    }
}
